load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")
load("@rules_proto_grpc//go:defs.bzl", "go_grpc_library")

package(
    default_testonly = 1,
    default_visibility = ["//:__subpackages__"],
)

licenses(["notice"])

go_grpc_library(
    name = "testing_api_go_grpc",
    importpath = "github.com/google/tink/testing/go/proto/testing_api_go_grpc",
    protos = ["//proto:testing_api_proto"],
)

go_library(
    name = "services",
    srcs = [
        "aead_service.go",
        "annotated_keyset.go",
        "daead_service.go",
        "hybrid_service.go",
        "jwt_service.go",
        "keyset_service.go",
        "mac_service.go",
        "metadata_service.go",
        "prf_set_service.go",
        "signature_service.go",
        "streaming_aead_service.go",
    ],
    importpath = "github.com/google/tink/testing/go/services",
    deps = [
        ":testing_api_go_grpc",
        "@org_golang_google_protobuf//proto",
        "@org_golang_google_protobuf//types/known/structpb",
        "@org_golang_google_protobuf//types/known/timestamppb",
        "@org_golang_google_protobuf//types/known/wrapperspb",
        "@tink_go//aead",
        "@tink_go//daead",
        "@tink_go//hybrid",
        "@tink_go//insecurecleartextkeyset",
        "@tink_go//jwt",
        "@tink_go//keyset",
        "@tink_go//mac",
        "@tink_go//prf",
        "@tink_go//proto/tink_go_proto",
        "@tink_go//signature",
        "@tink_go//streamingaead",
    ],
)

go_test(
    name = "services_test",
    size = "small",
    srcs = [
        "jwt_service_test.go",
        "services_test.go",
    ],
    deps = [
        ":services",
        ":testing_api_go_grpc",
        "@com_github_google_go_cmp//cmp",
        "@org_golang_google_protobuf//proto",
        "@org_golang_google_protobuf//testing/protocmp",
        "@org_golang_google_protobuf//types/known/durationpb",
        "@org_golang_google_protobuf//types/known/structpb",
        "@org_golang_google_protobuf//types/known/timestamppb",
        "@org_golang_google_protobuf//types/known/wrapperspb",
        "@tink_go//aead",
        "@tink_go//daead",
        "@tink_go//hybrid",
        "@tink_go//jwt",
        "@tink_go//keyset",
        "@tink_go//mac",
        "@tink_go//prf",
        "@tink_go//signature",
        "@tink_go//streamingaead",
    ],
)

go_binary(
    name = "testing_server",
    srcs = [
        "testing_server.go",
    ],
    deps = [
        ":services",
        ":testing_api_go_grpc",
        "@org_golang_google_api//option",
        "@org_golang_google_grpc//:grpc",
        "@tink_go//core/registry",
        "@tink_go//integration/awskms",
        "@tink_go//integration/gcpkms",
        "@tink_go//testing/fakekms",
    ],
)
